import http from '../utils/http.js'
import axios from 'axios'

//查询所有标签
function showContentByPage(obj) {
    return http({
        method: 'post',
        url: '/admin/content/showContentByPage',
        params: obj
    })
}

//条件模糊查询内容
function showContentByCondition(obj) {
    return http({
        method: 'post',
        url: '/admin/content/showContentByCondition',
        params: obj
    })
}

// 批量修改内容状态
function updateContentState(obj) {
    return http({
        method: 'post',
        url: '/admin/content/updateContentState',
        params: obj
    })
}

//通过id删除/批量删除内容
function removeContentByIds(ids) {
    return http({
        method: 'post',
        url: '/admin/content/portal/removeContentByIds',
        params: {
            ids: ids
        }
    })
}

//内容保存/修改
function UpdateContent(obj) {
    console.log(obj)
    return http({
        method: 'post',
        url: '/admin/content/UpdateContent',
        params: obj
    })
}

//上传文件
function uploadFile(file) {
    console.log('file',file)
   return  axios({
        method: 'post',
        url: 'http://42.192.83.237:8080/admin/content/uploadContentImage',
        headers: {
            "Content-Type": "multipart/form-data",
            token:sessionStorage.getItem('token')
        },
        data: {
            mpFile:file
        }
    })
}
//添加内容
function AddContent() {
    return http({
        method: 'post',
        url: '/admin/content/addContent',
    })
}
// 通过id查询内容
function findContentById(id){
    return http({
        method: 'post',
        url: '/admin/content/portal/findContentById',
        params:{
            id:id
        }
    })
}
export {
    showContentByPage,
    showContentByCondition,
    updateContentState,
    removeContentByIds,
    UpdateContent,
    uploadFile,
    AddContent,
    findContentById
}